package com.artpri.action.user;

import java.util.List;
import java.util.Map;

import com.artpri.action.BaseAction;
import com.artpri.model.CollectShopkeeper;
import com.artpri.model.ShopkeeperInfo;
import com.artpri.service.AdPictureService.ImageState;
import com.artpri.service.AttentionCenterService.AttentionType;

/**
 * 关注店铺
 * @author ZhangSi
 *
 */
public class CollectStoreAction extends BaseAction{

	private static final long serialVersionUID = 8831076635642852971L;

	private List<CollectShopkeeper> collectList;
	
	private List<Integer> ids;
	
	private String msg;
	
	private Integer pageNo;
	private Integer totalRecords;
	private Integer pageSize;
	
	private Map<String, ShopkeeperInfo> recStoreMap;
	
	public String listCollect() throws Exception {
		int userNum = getSessionUser().getUserNum();
		totalRecords = getAttentionCenterService().getResultCount(AttentionType.STORE, userNum);
		collectList = getAttentionCenterService().listStoreCollectByPage(userNum, getPageNo(), pageSize);
		recStoreMap = getAdPictureService().getRecStoreMapByPlate("00205", ImageState.SHOW);
		return SUCCESS;
	}


	public String cancelCollect() throws Exception {
		getAttentionCenterService().cancelCollectStore(ids);
		msg=SUCCESS;
		return SUCCESS;
	}
	
	public List<CollectShopkeeper> getCollectList() {
		return collectList;
	}
	public void setCollectList(List<CollectShopkeeper> collectList) {
		this.collectList = collectList;
	}
	public List<Integer> getIds() {
		return ids;
	}
	public void setIds(List<Integer> ids) {
		this.ids = ids;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Integer getPageNo() {
		pageNo = pageNo == null ? 1 : pageNo;
		return pageNo;
	}
	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}
	public Integer getTotalPage() {
		return totalRecords%pageSize==0 ? totalRecords/pageSize : totalRecords/pageSize +1;
	}
	public Integer getTotalRecords() {
		return totalRecords;
	}
	public void setTotalRecords(Integer totalRecords) {
		this.totalRecords = totalRecords;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Map<String, ShopkeeperInfo> getRecStoreMap() {
		return recStoreMap;
	}
	public void setRecStoreMap(Map<String, ShopkeeperInfo> recStoreMap) {
		this.recStoreMap = recStoreMap;
	}
}
